'\" t
.TH "SD_JOURNAL_GET_SEQNUM" "3" "" "systemd 257" "sd_journal_get_seqnum"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_journal_get_seqnum \- Read sequence number from the current journal entry
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-journal\&.h>
.fi
.ft
.HP \w'int\ sd_journal_get_seqnum('u
.BI "int sd_journal_get_seqnum(sd_journal\ *" "j" ", uint64_t\ *" "ret_seqnum" ", sd_id128_t\ *" "ret_seqnum_id" ");"
.SH "DESCRIPTION"
.PP
\fBsd_journal_get_seqnum()\fR
returns the sequence number of the current journal entry\&. It takes three arguments: the journal context object, a pointer to a 64\-bit unsigned integer to store the sequence number in, and a buffer to return the 128\-bit sequence number ID in\&.
.PP
When writing journal entries to disk each
\fBsystemd\-journald\fR
instance will number them sequentially, starting from 1 for the first entry written after subsystem initialization\&. Each such series of sequence numbers is associated with a 128\-bit sequence number ID which is initialized randomly, once at
\fBsystemd\-journal\fR
initialization\&. Thus, while multiple instances of
\fBsystemd\-journald\fR
will assign the same sequence numbers to their written journal entries, they will have a distinct sequence number IDs\&. The sequence number is assigned at the moment of writing the entry to disk\&. If log entries are rewritten (for example because the volatile logs from
/run/log/
are flushed to
/var/log/
via
systemd\-journald\-flush\&.service) they will get new sequence numbers assigned\&.
.PP
Sequence numbers may be used to order entries (entries associated with the same sequence number ID and lower sequence numbers should be ordered chronologically before those with higher sequence numbers), and to detect lost entries\&. Note that journal service instances typically write to multiple journal files in parallel (for example because
\fISplitMode=\fR
is used), in which case each journal file will only contain a subset of the sequence numbers\&. To recover the full stream of journal entries the files must be combined ("interleaved"), a process that primarily relies on the sequence numbers\&. When journal files are rotated (due to size or time limits), the series of sequence numbers is continued in the replacement files\&. All journal files generated from the same journal instance will carry the same sequence number ID\&.
.PP
As the sequence numbers are assigned at the moment of writing the journal entries to disk they do not exist if storage is disabled via
\fISplitMode=\fR\&.
.PP
The
\fIret_seqnum\fR
and
\fIret_seqnum_id\fR
parameters may be specified as
\fBNULL\fR
in which case the relevant data is not returned (but the call will otherwise succeed)\&.
.PP
Note that these functions will not work before
\fBsd_journal_next\fR(3)
(or related call) has been called at least once, in order to position the read pointer at a valid entry\&.
.SH "RETURN VALUE"
.PP
\fBsd_journal_get_seqnum()\fR
returns 0 on success or a negative errno\-style error code\&.\&.
.SH "NOTES"
.PP
All functions listed here are thread\-agnostic and only a single specific thread may operate on a given object during its entire lifetime\&. It\*(Aqs safe to allocate multiple independent objects and use each from a specific thread in parallel\&. However, it\*(Aqs not safe to allocate such an object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don\*(Aqt operate on it at the very same time\&.
.PP
Functions described here are available as a shared library, which can be compiled against and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.SH "HISTORY"
.PP
\fBsd_journal_get_seqnum()\fR
was added in version 254\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1), \fBsd-journal\fR(3), \fBsd_journal_open\fR(3), \fBsd_journal_next\fR(3), \fBsd_journal_get_data\fR(3), \fBsd_journal_get_monotonic_usec\fR(3)
